layui.define(['jquery'],
    function (exports) {
        var $ = layui.jquery;
        var layer = layui.layer;
        var watermark = layui.watermark;
        var kaLayer = new function () {
            this.v1 = function (params) { // 自定义 V1 从上往下
                var id = params.id;
                if (id == undefined) {
                    id = "kA_LAYER_" + (new Date()).getTime(); 
                }
                var callBack = params.success;
                layer.open({
                    type: 1,
                    offset: 't',
                    anim: 'slideDown', // 从上往下
                    area: params.area,
                    shade: [0.6, '#FFF'],
                    shadeClose: true,
                    move: false,
                    title: params.title,
                    id: id,
                    content: params.content,
                    success: function(layero, index, that){
                        loadingWatermark(watermark, { id: ".layui-layer-page" });
                        typeof callBack == "function" && callBack(layero, index, that);
                    }
                });
            }
            this.v2 = function (params) { // 左侧
                var id = params.id;
                if (id == undefined) {
                    id = "kA_LAYER_" + (new Date()).getTime(); 
                }
                var area = [];
                if (/Mobi|Android|iPhone/i.test(navigator.userAgent)) {
                    area = ["90%","100%"];
                } else {
                    area = ["50%","100%"];
                }
                var callBack = params.success;
                layer.open({
                    type: 1,
                    offset: 'r',
                    anim: 'slideLeft', // 从上往下
                    area: area,
                    move: false,
                    shade: [0.6, '#FFF'],
                    shadeClose: true,
                    title: params.title,
                    id: id,
                    content: params.content,
                    success: function(layero, index, that){
                        loadingWatermark(watermark, { id: ".layui-layer-page" });
                        typeof callBack == "function" && callBack(layero, index, that);
                    }
                });
            }
        };
        exports('kaLayer', kaLayer);
    }
)